﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.XPath;

namespace TreasAuction
{
    class PendingAnnouncementData
    {
        private String termWeekYear;
        private String termDayMonth;
        private String type;
        private String cusip;
        private String announceDate;
        private String actnDate;
        private String issDate;

        internal PendingAnnouncementData[] createData(XPathDocument document)
        {
            List<PendingAnnouncementData> list = new List<PendingAnnouncementData>();

            XPathNavigator navigator = document.CreateNavigator();
            XPathNodeIterator nodeIterator = navigator.Select("//SecurityTermWeekYear");

            for (XPathNavigator node = nodeIterator.Current; nodeIterator.MoveNext(); )
            {
                PendingAnnouncementData temp = new PendingAnnouncementData();
                temp.SecurityTermWeekYear = node.InnerXml;
                list.Add(temp);
            }

            nodeIterator = navigator.Select("//SecurityTermDayMonth");
            int i = 0;
            for (XPathNavigator node = nodeIterator.Current; nodeIterator.MoveNext(); )
            {
                PendingAnnouncementData temp = list.ElementAt(i);
                temp.SecurityTermDayMonth = node.InnerXml;
                i++;
            }

            nodeIterator = navigator.Select("//SecurityType");
            i = 0;
            for (XPathNavigator node = nodeIterator.Current; nodeIterator.MoveNext(); )
            {
                PendingAnnouncementData temp = list.ElementAt(i);
                temp.SecurityType = node.InnerXml;
                i++;
            }

            nodeIterator = navigator.Select("//CUSIP");
            i = 0;
            for (XPathNavigator node = nodeIterator.Current; nodeIterator.MoveNext(); )
            {
                PendingAnnouncementData temp = list.ElementAt(i);
                temp.CUSIP = node.InnerXml;
                i++;
            }

            nodeIterator = navigator.Select("//AnnouncementDate");
            i = 0;
            for (XPathNavigator node = nodeIterator.Current; nodeIterator.MoveNext(); )
            {
                PendingAnnouncementData temp = list.ElementAt(i);
                temp.AnnouncementDate = node.InnerXml;
                i++;
            }

            nodeIterator = navigator.Select("//AuctionDate");
            i = 0;
            for (XPathNavigator node = nodeIterator.Current; nodeIterator.MoveNext(); )
            {
                PendingAnnouncementData temp = list.ElementAt(i);
                temp.AuctionDate = node.InnerXml;
                i++;
            }

            nodeIterator = navigator.Select("//IssueDate");
            i = 0;
            for (XPathNavigator node = nodeIterator.Current; nodeIterator.MoveNext(); )
            {
                PendingAnnouncementData temp = list.ElementAt(i);
                temp.IssueDate = node.InnerXml;
                i++;
            }

            return list.ToArray();
        }        

        internal String SecurityTermWeekYear
        {
            get
            {
                return termWeekYear;
            }
            set
            {
                this.termWeekYear = value;
            }
        }

        internal String SecurityTermDayMonth
        {
            get
            {
                return termDayMonth;
            }
            set
            {
                this.termDayMonth = value;
            }
        }

        internal String SecurityType
        {
            get
            {
                return type;
            }
            set
            {
                this.type = value;
            }
        }

        internal String CUSIP
        {
            get
            {
                return cusip;
            }
            set
            {
                this.cusip = value;
            }
        }

        internal String AnnouncementDate
        {
            get
            {
                return announceDate;
            }
            set
            {
                this.announceDate = value;
            }
        }

        internal String AuctionDate
        {
            get
            {
                return actnDate;
            }
            set
            {
                this.actnDate = value;
            }
        }

        internal String IssueDate
        {
            get
            {
                return issDate;
            }
            set
            {
                this.issDate = value;
            }
        }
    }
}
